/*
Copyright (C) 2021-2025 Casa Xu (also Zhiyan Xu) from HIT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*
 * LOS_CIOMPCam.h
 *
 *  Created on: 2022年8月7日
 *      Author: 64435
 */

#ifndef PERIPHERAL_LAYER_INC_LOS_CIOMPCAM_H_
#define PERIPHERAL_LAYER_INC_LOS_CIOMPCAM_H_

#include "LOS_SYS.h"

#define CIOMPCAM_MAXNUM LOS_MAX14830_NUM1
#define CIOMPCAM_MAXPort 2

typedef struct LOS_CIOMPCam_t
{
    uint8_t VAL;    //数据有效性标志，0：有效， 其他值：无效
    uint8_t CMD;    //开关机指令状态,发送开机指令后置1，发送关机指令后置0
    uint8_t PWR;    //电源状态，读取电源遥测，通电为1，断电为0
    uint8_t MSG;    //通信状态，通信正常为0，通信异常为其他值
    uint8_t SWNUM;
    uint8_t RBCNT;  //复位次数
    uint8_t NFR;                 //Need For Reset 需要复位标志位，1为需要复位，0为不需要
    uint8_t HL_TXF; //HL_前缀表示健康管理相关变量。遥测请求发送完成标志,发送一次后该量置1，接收到回应后置0(TX FINISHED)
    uint8_t HL_WCNT;//等待接收计数器。该计数器在操作系统的一个线程中累加，当HL_TXF为1时该值+1，HL_TXF为0时该值清0，当累加到一定值时系统会判断通信异常，并将MSG置1
    uint32_t TMCNT;
    uint8_t TMMSG[29];
    uint8_t sumflag;  //校验和标志位 0X55为错误 0xAA为正确
}LOS_CIOMPCam_t;

LOS_CIOMPCam_t STA_CIOMPCam;

extern uint8_t TMPACK_CIOMPCam[45];

void LOS_CIOMPCam_Snap();
void LOS_CIOMPCam_SetMode(uint8_t checkmode, uint8_t cammode, uint8_t checkimg, uint8_t expomode);
void LOS_CIOMPCam_Stop();
void LOS_CIOMPCam_SetTime(uint32_t second);
void LOS_CIOMPCam_PPSSelect(uint8_t PPS);
void LOS_CIOMPCam_SetGain(uint8_t Gain);
void LOS_CIOMPCam_SetFramePeriod(uint32_t Period);
void LOS_CIOMPCam_SetExposureTime(uint32_t Time);
void LOS_CIOMPCam_SetCMOSDirection(uint8_t Direction);
void LOS_CIOMPCam_GetState();
void LOS_CIOMPCam_SetVFirstLine(uint16_t Line);
void LOS_CIOMPCam_SetSFirstLine(uint16_t Line);
void LOS_CIOMPCam_SelectBit(uint8_t Bit);
void LOS_CIOMPCam_FPNCorrection(uint8_t par1);
void LOS_CIOMPCam_SDPCCorrection(uint8_t par1);
void LOS_CIOMPCam_Config(uint8_t par1, uint8_t par2);
void LOS_CIOMPCam_ProgressionSet(uint8_t par1);
void LOS_CIOMPCam_AuxiliaryData(uint8_t* par);
void LOS_CIOMPCam_CallBack(uint8_t* msg);
void LOS_CAM_PWROn();
void LOS_CAM_PWROff();

#endif /* PERIPHERAL_LAYER_INC_LOS_CIOMPCAM_H_ */
